//公共
import myHeader from "/pages/headerfoot/pages/header.vue"
//公共底部
import Tabbar from "/pages/headerfoot/pages/benefitfooter.vue";
//骨架
import uniSkeleton from "/plugin/skeleton/components/heaven-skeleton/heaven-skeleton.vue";
//公共公益方法
import commonBenefit from '@/common/commonbenefit.js';
//公共方法
import Base from '@/common/base.js';
//语言
import Lang from '@/utils/lang.js';
//微信api
import weChat from '@/lib/wechat.js';
//cache缓存
import Cache from '@/utils/cache.js';
//无数据
import pagesEmpty from "/plugin/pages-empty/components/pages-empty/pages-empty.vue";
 
 
export default {
	components: {
		Tabbar,
		myHeader,
		uniSkeleton,
		pagesEmpty,
	},
	data() {
		return {
			loading: true, //骨架
			toptitle: Lang.lang.trainingrecord, //头部
			list: {}, //结果
			url: commonBenefit.automaticurl('projectanswerend'), //跳转
			userid:0,//用户
			lang: Lang.lang,//语言
			type:1,
		}
	},
 
	onShow() {
		var that = this;
		that.ifreglogin();
	
	},
	onLoad(option) {
		var that = this;
		if(option.userid){
			//老师查看
			 that.userid=option.userid;//用户ID
		}else{
			//自己查看
			 that.userid=Cache.get('userid');//用户ID
		}
		that.getdata();
	},
	
	methods: {
		//获取数据
		getdata(type){
			var that = this;
			that.list=[];
			var data={};
			if(type){
				that.type=type;
			}
			data['user_id']=that.userid;
			data['type'] =that.type;//类型 1=语言 2=数学
			commonBenefit.getUserHistoryProjectListApiMethod(data).then(res => {
				if (res) {
					that.list = res; //结果
					that.loading = false;
				}
			})
		},
		//判断是否需要注册或者登录与其他
		async ifreglogin() {
			var that = this;
			//注册
			await Base.globalauthorization();
			//判断学生是否注册
			await commonBenefit.ifStudenter().then(res => {
				if (res) {
					uni.redirectTo({
						url: commonBenefit.automaticurl('studentreg')
					})
				}
			});
		},
	}
}